<template>
  <div class="newsInfo">
    <header>
      <h1 class="title">{{newsinfo.title}}</h1>
      <div class="btn-group">
        <span class="add-time">{{newsinfo.add_time}}</span>
        <span>点击{{newsinfo.click}}次</span>
      </div>
      <hr />
    </header>

    <!-- 内容区域 -->
    <div class="content">
      {{newsinfo.content}}
    </div>

    <!-- 评论区域 做渲染-->
    <Comment></Comment>

  </div>
</template>
<script>
import Comment from '@/components/Comment'
export default {
  data: () => ({
    id: 0,
    newsinfo: {}
  }),
  created () {
    this.id = this.$route.params.id
    this.getnew()
  },
  methods: {
    async getnew () {
      const {
        data: { status, message }
      } = await this.$axios.get('api/getnew/' + this.id)
      if (status !== 0) this.$Toast(message)
      console.log(message)
      this.newsinfo = message
    }
  },
  components: {
    Comment
  }
}
</script>
<style lang="less" scoped>
.newsInfo{
  padding: 0px 8px;
  header{
    h1{
      text-align: center;
    }
    .title{
      font-size: 16px;
      color:red;
    }
    .btn-group{
      font-size: 12px;
      display: flex;
      justify-content: space-between;
      .add-time{
        color: blue
      }
    }
  }
}
</style>
